package com.arcaneshift.security.errors;

import com.common.security.abstracts.AbstractError;

/**
 * Error code range: 21 - 40
 * 
 * @author Ady
 *
 */
public class CredentialsError extends AbstractError {
	
	public static final int NO_USERNAME_PROVIDED = 21;
	private static final String MESSAGE_NO_USERNAME_PROVIDED = "Username was not provided";
	private static final String CAUSE_NO_USERNAME_PROVIDED = "You forgot to write your username";
	private static final String DESCRIPTION_NO_USERNAME_PROVIDED = "Write down your username and try again";
	
	public static final int NO_PASSWORD_PROVIDED = 22;
	private static final String MESSAGE_NO_PASSWORD_PROVIDED = "The password was not provided";
	private static final String CAUSE_NO_PASSWORD_PROVIDED = "You forgot to write your password";
	private static final String DESCRIPTION_NO_PASSWORD_PROVIDED = "Write down your password and try again";
	
	public static final int USERNAME_BAD_FORMAT = 23;
	private static final String MESSAGE_USERNAME_BAD_FORMAT = "Username was provided in a bad format";
	private static final String CAUSE_USERNAME_BAD_FORMAT = "The username was either too short, too long or had forbidden characters";
	private static final String DESCRIPTION_USERNAME_BAD_FORMAT = "Username must have from 10 to 25 characters";
	
	public static final int PASSWORD_BAD_FORMAT = 24;
	private static final String MESSAGE_PASSWORD_BAD_FORMAT = "The password was provided in a bad format";
	private static final String CAUSE_PASSWORD_BAD_FORMAT = "The password was either too short, too long or had forbidden characters";
	private static final String DESCRIPTION_PASSWORD_BAD_FORMAT = "Password must have from 10 to 30 characters";
	
	public static final int USERNAME_EXISTS = 25;
	private static final String MESSAGE_USERNAME_EXISTS = "The username allready exists";
	private static final String CAUSE_USERNAME_EXISTS = "A duplicate of this username was found";
	private static final String DESCRIPTION_USERNAME_EXISTS = "Try with another username";
	
	public static final int MULTIPLE_USERNAMES_FOUND = 26;
	private static final String MESSAGE_MULTIPLE_USERNAMES_FOUND = "The username was multiplied over database";
	private static final String CAUSE_MULTIPLE_USERNAMES_FOUND = "Two or more users wore found with the same username";
	private static final String DESCRIPTION_MULTIPLE_USERNAMES_FOUND = "The administrator will resolve this issue, until then all those accounts will be blocked";
	
	public static final int USER_PASSWORD_NOT_MATCH = 27;
	private static final String MESSAGE_USER_PASSWORD_NOT_MATCH = "The username and password does not match";
	private static final String CAUSE_USER_PASSWORD_NOT_MATCH = "The username does not exist or the password was wrong";
	private static final String DESCRIPTION_USER_PASSWORD_NOT_MATCH = "Write down your username and password and try again";
	
	public CredentialsError(int code) {
		super(code);
		
		switch (code) {
			case NO_USERNAME_PROVIDED: {
				setMessage(MESSAGE_NO_USERNAME_PROVIDED);
				setCause(CAUSE_NO_USERNAME_PROVIDED);
				setDescription(DESCRIPTION_NO_USERNAME_PROVIDED);
				break;
			}
			case NO_PASSWORD_PROVIDED: {
				setMessage(MESSAGE_NO_PASSWORD_PROVIDED);
				setCause(CAUSE_NO_PASSWORD_PROVIDED);
				setDescription(DESCRIPTION_NO_PASSWORD_PROVIDED);
				break;
			}
			case USERNAME_BAD_FORMAT: {
				setMessage(MESSAGE_USERNAME_BAD_FORMAT);
				setCause(CAUSE_USERNAME_BAD_FORMAT);
				setDescription(DESCRIPTION_USERNAME_BAD_FORMAT);
				break;
			}
			case PASSWORD_BAD_FORMAT: {
				setMessage(MESSAGE_PASSWORD_BAD_FORMAT);
				setCause(CAUSE_PASSWORD_BAD_FORMAT);
				setDescription(DESCRIPTION_PASSWORD_BAD_FORMAT);
				break;
			}
			case USERNAME_EXISTS: {
				setMessage(MESSAGE_USERNAME_EXISTS);
				setCause(CAUSE_USERNAME_EXISTS);
				setDescription(DESCRIPTION_USERNAME_EXISTS);
				break;
			}
			case MULTIPLE_USERNAMES_FOUND: {
				setMessage(MESSAGE_MULTIPLE_USERNAMES_FOUND);
				setCause(CAUSE_MULTIPLE_USERNAMES_FOUND);
				setDescription(DESCRIPTION_MULTIPLE_USERNAMES_FOUND);
				break;
			}
			case USER_PASSWORD_NOT_MATCH: {
				setMessage(MESSAGE_USER_PASSWORD_NOT_MATCH);
				setCause(CAUSE_USER_PASSWORD_NOT_MATCH);
				setDescription(DESCRIPTION_USER_PASSWORD_NOT_MATCH);
				break;
			}
		}
	}
}
